<template>

  <div>

    <center><h1>扫码支付</h1></center>


    <a-form-item v-bind="formItemLayout" label="金额">
      <a-input v-model="money"/>
    </a-form-item>
    <a-form-item v-bind="tailFormItemLayout">
      <a-button type="primary" html-type="submit" @click="submit">
        生成二维码
      </a-button>
    </a-form-item>


    <a-form-item v-bind="formItemLayout" label="二维码">

      <img :src="src"/>

    </a-form-item>

    <a-button type="primary" html-type="submit" @click="getorder">
      获取结果
    </a-button>


  </div>

</template>


<script>

export default {
  data() {
    return {
      money: " ",
      src: "",
      uid: localStorage.getItem('uid'),
      orderid: '',
      formItemLayout: {
        labelCol: {
          xs: {span: 16},
          sm: {span: 4},
        },
        wrapperCol: {
          xs: {span: 16},
          sm: {span: 8},
        },
      },
      tailFormItemLayout: {
        wrapperCol: {
          xs: {
            span: 16,
            offset: 0,
          },
          sm: {
            span: 8,
            offset: 4,
          },
        },
      },
      dataSource: [
        {
          key: '0',
          name: 'Edward King 0',
          age: '32',
          address: 'London, Park Lane no. 0',
        },
        {
          key: '1',
          name: 'Edward King 1',
          age: '32',
          address: 'London, Park Lane no. 1',
        },
      ],
      columns: [
        {
          title: 'name',
          dataIndex: 'name',
        },
        {
          title: 'age',
          dataIndex: 'age',
        },
        {
          title: 'address',
          dataIndex: 'address',
        },
        {
          title: 'operation',
          dataIndex: 'operation',
          scopedSlots: {customRender: 'operation'},
        },
      ],
    };
  },
  methods: {

    getorder() {

      this.$axios({
        url: '/z/wx_pay/',
        method: 'post',
        data: {'orderid': this.orderid, 'uid': this.uid}
      }).then(res => {
        console.log(res.data)
      })
    },

    submit:function() {

      this.$axios.get('/z/wx_pay/?uid=' + this.uid + '&money=' + this.money).then(result => {

        console.log(result.data);

        this.src = "http://127.0.0.1:8000/media/" + result.data.img
        this.orderid = result.data.orderid

      });

      onDelete(key)
      {
        console.log(this.dataSource[key]);
      }
    }
  }
};
</script>
